<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="~{shared/header(Mytitle='首页')}"/>
<body class="bg-gray-100 font-sans flex flex-col h-screen">
<nav th:replace="~{shared/nav}"/>
<div th:replace="~{shared/modal}"/>

<div class="flex-grow flex items-center justify-center text-blue-600">
    <div class="container mx-auto p-8 flex">
        <div class="container mx-auto p-8 flex">

            <!-- 右半边 -->
            <div class="w-1/2 pl-8">
                <p class="text-xl text-gray-800">
                    Ceddin，deden，neslin，baban<br>
                    Ceddin，deden，neslin，baban<br>
                    Hep kahraman Türk milleti<br>
                    Orduların，pek çok zaman，ver miştiler dünyaya şan<br>
                    Orduların，pek çok zaman，ver miştiler dünyaya şan<br>
                    <br>
                    Türk milleti，Türk milleti<br>
                    Türk milleti，Türk milleti<br>
                    Aşk ile sev milliyeti，<br>
                    Kahret vatan düşmanını，çeksin o mel'un zilleti<br>
                    Kahret vatan düşmanını，çeksin o mel'un zilleti
                    <!-- 更多项目介绍内容 -->
                </p>
            </div>
            <!-- 左半边 -->
            <div class="w-1/2">
                <h1 class="text-4xl font-bold text-gray-800 mb-4">大问答模型，基于大模型的问答模型</h1>
                <div class="text-gray-600 mb-2">
                    <span class="font-bold">笑点解析:</span> 忍俊不禁
                </div>
                <div class="text-gray-600">
                    <!-- 其他信息 -->
                </div>

                <!-- 登录和注册按钮 -->
                <div class="mt-32">
                    <a href="/SS/login" class="bg-blue-500 text-white font-bold py-2 px-4 rounded mr-2">Login</a>
                    <a href="/SS/register" class="bg-green-500 text-white font-bold py-2 px-4 rounded">Register</a>
                </div>
            </div>
        </div>
    </div>
    <footer th:replace="~{shared/footer}"/>
</body>
</html>
<script th::inline="javascript">
    var onshow = true; //标记是否在展示
    function switchStatus() {
        if (onshow) { //在展示就切换成编辑
            $('#show').addClass('hidden')
            $('#edit').removeClass('hidden')
        } else { //反之
            $('#show').removeClass('hidden')
            $('#edit').addClass('hidden')
        }
        onshow = !onshow
    }

    $('#update').submit(function (event) {
        event.preventDefault()
        const formData = {
            name: $('#name').val(),
            email: $('#email').val(),
            gender: $('input[name="gender"]:checked').val(),
            description: $('#description').val(),
            phone: $('#phone').val()
        };
        // 过滤掉空值字段
        const filteredData = {};
        $.each(formData, function (key, value) {
            if (value !== '') {
                filteredData[key] = value;
            }
        });
        console.log(filteredData)
        // 检查是否有填写的字段，如果没有，给出提示
        if (Object.keys(filteredData).length === 0) {
            showModal("错误", "请至少输入一个字段", 'error')
            return;
        }

        $.ajax({
            type: 'POST',
            url: `${WebPrefix}/user/update`,
            data: JSON.stringify(filteredData),
            contentType: "application/json",
            dataType: "json",
            success: function (response) {
                showModal('result', response.message, response.result ? 'success' : 'error')
            },
            error: function (error) {
                console.error('提交表单时出错：', error)
            }
        });
    })

    window.onload = function() {
        redirectCheck();
    };

    function redirectCheck(){
        if ([[${errorMessage}]]){
            showModal('错误','请先登录您的账号','error')
        }
    }

</script>

